import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class dxk extends StatefulWidget {
  double totalPrice;

  dxk(this.totalPrice);

  @override
  _dxkState createState() => _dxkState();
}

class _dxkState extends State<dxk> {
  void initState() {
    monysNums = widget.totalPrice;
  }

  //支付宝图片路径
  String lj = "images/pay_select.png";

  //微信支付
  String lj2 = "images/pay_select.png";

  //单选框的选择
  bool dj = true;
  bool dj2 = true;

  //判断选中支付宝还是微信 默认支付宝
  String pay = "wxpay";

  //充值金额
  double monysNums;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('订单支付页面'),
          leading: new IconButton(
            icon: new Icon(
              Icons.chevron_left,
              size: 35.0,
            ),
            onPressed: () => Navigator.of(context).pop(),
          ),
        ),
        body: SingleChildScrollView(
          child: Column(
            children: <Widget>[
              Container(
                margin: const EdgeInsets.fromLTRB(20, 10, 0, 0),
                child: Text(monysNums.toStringAsFixed(4)),
//                child: TextField(
//                  最大行数
//
//                  maxLines: 1,
//                  keyboardType: TextInputType.number,
//                  decoration: InputDecoration(
//                    contentPadding: EdgeInsets.all(10.0),
//                    icon: Icon(
//                      Icons.attach_money,
//                      color: Colors.black,
//                    ),
//                    labelText: '请输入你要充值的金额',
//                    helperText: '充值金额不能为空',
//                  ),
//                            onChanged: _textFieldChanged,
//                  autofocus: true,
//                  onChanged: (value) {
//                    monysNums = value;
//                  },
              ),
//              new ListTile(
//                title: Container(
//                  child: Stack(
//                    children: <Widget>[
//                      Image.asset(
//                        'images/wechat_pay.png',
//                        height: ScreenUtil().setHeight(106),
//                        width: ScreenUtil().setWidth(190),
//                      ),
//                      new Align(
//                        alignment: FractionalOffset.centerRight,
//                        child: Image.asset(
//                          "${lj}",
//                          width: ScreenUtil().setWidth(55),
//                          height: ScreenUtil().setHeight(70),
//                        ),
//                      ),
//                    ],
//                  ),
//                ),
////                          trailing: Icon(Icons.chevron_right),
//                onTap: () {
//                  setState(() {
//                    if (dj) {
//                      pay = "ailipay";
//                      lj2 = "images/pay_noselect.png";
//                      lj = "images/pay_select.png";
//                      dj = false;
//                      dj2 = true;
//                    } else {
//                      lj = "images/pay_noselect.png";
//                      dj = true;
//                    }
//                  });
//                },
//              ),
              new ListTile(
                title: Container(
                  child: Row(
                    children: <Widget>[
                      new Align(
                          alignment: FractionalOffset.center,
                          child: Image.asset(
                            'images/wechat_pay.png',
                            height: ScreenUtil().setHeight(120),
                            width: ScreenUtil().setWidth(260),
                          )),

//                                new Text('昵称'),
                      Expanded(
                        child: Text(''), // 中间用Expanded控件
                      ),
                      new Align(
                        alignment: FractionalOffset.centerRight,
                        child: Image.asset(
                          "${lj2}",
                          width: ScreenUtil().setWidth(120),
                          height: ScreenUtil().setHeight(260),
                        ),
                      ),
                    ],
                  ),
                ),
//                          trailing: Icon(Icons.chevron_right),
                onTap: () {
                  setState(() {
                    if (dj2) {
                      pay = "wxpay";
                      lj = "images/pay_noselect.png";
                      lj2 = "images/pay_select.png";
                      dj2 = false;
                      dj = true;
                    } else {
                      lj2 = "images/pay_noselect.png";
                      dj2 = true;
                    }
                  });
                },
              ),
              new Container(
                height: 45.0,
                margin: EdgeInsets.fromLTRB(10, 70, 10, 0),
                child: new SizedBox.expand(
                  child: new RaisedButton(
                    onPressed: () {
//                      //判断是哪个支付
//                      ToastUtil.showToast("选中的是${pay}充值金额为:${monysNums}");
                    },
//                          color: Color.fromARGB(255, 61, 203, 128),
                    color: Colors.deepOrangeAccent,
                    child: new Text(
                      '支付',
                      style: TextStyle(
                          fontSize: 14.0,
                          color: Color.fromARGB(255, 255, 255, 255)),
                    ),
//                              shape: new RoundedRectangleBorder(
//                                  borderRadius: new BorderRadius.circular(45.0)),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
      theme: ThemeData(
        primaryColor: Colors.deepOrangeAccent,
      ),
    );
  }
}
